package org.zero.mapstruct.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import org.zero.model.dto.AccountDTO;
import org.zero.model.po.AccountPO;
import org.zero.model.vo.AccountVO;

/**
 * @author Zero (cnzeropro@qq.com)
 * @date 2021/9/4 16:00
 */
@Mapper(componentModel = "spring")
public interface AccountMapper {
    AccountMapper INSTANCE = Mappers.getMapper(AccountMapper.class);

    @Mappings({
            @Mapping(target = "status",
                    expression = "java(org.zero.util.EnumUtils.getEnum(org.zero.model.constant.StatusEnum.class,source.getStatus()))")
    })
    AccountDTO po2Dto(AccountPO source);

    @Mappings({
            @Mapping(target = "status",
                    expression = "java(org.zero.util.EnumUtils.getOtherKey(org.zero.model.constant.StatusEnum.class,source.getStatus(),\"name\",java.lang.String.class))")
    })
    AccountVO po2Vo(AccountPO source);
}
